import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index'
import cart from '@/components/cart'
import item from '@/components/item'
import detail from '@/components/detail'
import mytest from '@/components/mytest'
import test from '@/components/test'
import register from '@/components/register'
import login from '@/components/login'
import register2 from '@/components/register2'
import myprofile from '@/components/myprofile'
import week from '@/components/we/week'
import uppy from '@/components/we/uppy'
import addgoods from '@/components/addgoods'
import search from '@/components/search'
import weekgoodlist from '@/components/we/weekgoodlist'
import details from '@/components/we/details'
import punch from '@/components/we/punch'
import learnlogin from '@/components/shopping/learnlogin'
import learngoods from '@/components/shopping/learngoods'
import learnorder from '@/components/shopping/learnorder'
import coslogin from '@/components/cos/coslogin'
import cosshow from '@/components/cos/cosshow'
import cosdetails from '@/components/cos/cosdetails'
import studyshow from '@/components/mystudy/studyshow'
import studylogin from '@/components/mystudy/studylogin'
import studycommit from '@/components/mystudy/studycommit'
import showcommit from '@/components/mystudy/showcommit'
import lifalogin from '@/components/shopping/lifalogin'
import lifatop from '@/components/shopping/lifatop'
import myuplogin from '@/components/shopping/myuplogin'
import myupshows from '@/components/shopping/myupshows'
import myupgoods from '@/components/shopping/myupgoods'
import myupcart from '@/components/shopping/myupcart'



Vue.use(Router)

var routes = [
        {
          path:'/',
          name:'index',
          component:index
        },
        {
          path:'/cart',
          name:'cart',
          component:cart
        },
        {
          path:'/item',
          name:'item',
          component:item
        },
        {
          path:'/detail',
          name:'detail',
          component:detail
        },
        {
          path:'/mytest',
          name:'mytest',
          component:mytest
        },
        {
          path:'/test',
          name:'test',
          component:test
        },
        {
          path:'/register',
          name:'register',
          component:register
        },
        {
          path:'/login',
          name:'login',
          component:login
        },
        {
          path:'/register2',
          name:'register2',
          component:register2
        }
        ,
        {
          path:'/myprofile',
          name:'myprofile',
          component:myprofile,
          beforeEnter: (to, from, next) => {
            if(localStorage.getItem('username')){
              console.log('已登录')
              next()
            }else{
              console.log('没有登录')
              next('/login')
            }
          }
        },
        {
          path:'/week',
          name:'week',
          component:week
        },
        {
          path:'/uppy',
          name:'uppy',
          component:uppy
        },
        {
          path:'/addgoods',
          name:'addgoods',
          component:addgoods
        },
        {
          path:'/search',
          name:'search',
          component:search
        },
        {
          path:'/weekgoodlist',
          name:'weekgoodlist',
          component:weekgoodlist
        }, 
        {
          path:'/details',
          name:'details',
          component:details
        },
        {
          path:'/punch',
          name:'punch',
          component:punch
        },
        {
          path:'/learnlogin',
          name:'learnlogin',
          component:learnlogin
        },
        {
          path:'/learngoods',
          name:'learngoods',
          component:learngoods,
          // beforeEnter: (to, from, next) => {
          //   if(localStorage.getItem('username')){
          //     console.log('已登录')
          //     next()
          //   }else{
          //     console.log('没有登录')
          //     next('/learnlogin')
          //   }
          // }
        },
        {
          path:'/learnorder',
          name:'learnorder',
          component:learnorder
        },   
        {
          path:'/coslogin',
          name:'coslogin',
          component:coslogin
        },
        {
          path:'/cosshow',
          name:'cosshow',
          component:cosshow
        },
        {
          path:'/cosdetails',
          name:'cosdetails',
          component:cosdetails
        },
        {
          path:'/studyshow',
          name:'studyshow',
          component:studyshow,
          beforeEnter: (to, from, next) => {
            if(localStorage.getItem('username')){
              console.log('已登录')
              next()
            }else{
              console.log('没有登录')
              next('/studylogin')
            }
          }
        },
        {
          path:'/studylogin',
          name:'studylogin',
          component:studylogin
        },
        {
          path:'/studycommit',
          name:'studcommit',
          component:studycommit
        },
        {
          path:'/showcommit',
          name:'showcommit',
          component:showcommit
        },
        {
          path:'/lifalogin',

          component:lifalogin
        },
        {
          path:'/lifatop',

          component:lifatop
        },
        {
          path:'/myuplogin',

          component:myuplogin
        },
        {
          path:'/myupshows',

          component:myupshows
        },
        {
          path:'/myupgoods',
          name:'myupgoods',
          component:myupgoods
        }, 
        {
          path:'/myupcart',
          name:'myupcart',
          component:myupcart
        }, 
       







]

export default new Router({
  routes:routes,
  mode:'history'   /*hash*/
})
